﻿@namespace BootstrapBlazor.Components
@inherits BootstrapModuleComponentBase

<div @attributes="@AdditionalAttributes" id="@Id" class="@ClassName" style="@StyleName" data-bs-ride="carousel" data-bs-touch="@DisableTouchSwipingString">
    <CascadingValue Value="this" IsFixed="true">
        @ChildContent
    </CascadingValue>
    <RenderTemplate>
        @if (ShowIndicators)
        {
            <ol class="carousel-indicators">
                @for (var index = 0; index < Items.Count; index++)
                {
                    <li data-bs-slide-to="@index" class="@CheckActive(index)" data-bs-target="@TargetId"></li>
                }
            </ol>
        }
        <div class="carousel-inner">
            @for (var index = 0; index < Items.Count; index++)
            {
                var item = Items[index];
                <div class="@CheckActive(index, "carousel-item")" data-bs-interval="@item.IntervalString">
                    @item.ChildContent
                    @if (item.ShowCaption)
                    {
                        <div class="@item.GetCaptionClassString">
                            @if (item.CaptionTemplate != null)
                            {
                                @item.CaptionTemplate
                            }
                            else
                            {
                                @item.Caption
                            }
                        </div>
                    }
                </div>
            }
        </div>
        @if (ShowControls)
        {
            <a class="carousel-control-prev" data-bs-slide="prev" @onclick:preventDefault href="@TargetId">
                <i class="fa-solid fa-angle-left"></i>
                <span class="sr-only">Previous</span>
            </a>
            <a class="carousel-control-next" data-bs-slide="next" @onclick:preventDefault href="@TargetId">
                <i class="fa-solid fa-angle-right"></i>
                <span class="sr-only">Next</span>
            </a>
        }
    </RenderTemplate>
</div>
